package operation.impl;

import book.Book;
import book.BookList;
import operation.IOperation;

public class AddOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("请输入书籍名称:");
        String booksName = scanner.next();
        // 判断书架上是否存在该书籍
        if (bookList.isContains(booksName)){
            System.out.println("已存在该书籍!");
        }else {
            System.out.println("请输入书籍作者:");
            String author = scanner.next();
            System.out.println("请输入书籍价格:");
            double price = scanner.nextDouble();
            System.out.println("请输入书籍类别:");
            String type = scanner.next();
            Book book = new Book(booksName, author, price, type);
            bookList.addBook(book);
            System.out.println("添加成功!");
        }
    }
}
